package com.example.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.dao.BookDao;
import com.example.domain.Book;
import com.example.util.Page;

@Service
public class BookService {
	@Autowired()
	BookDao bookDao;
	@Transactional
	public void save(Book book){
		bookDao.save(book);
	}
	@Cacheable("books")//新增缓存
	@Transactional
	public Book get(String id){
		return bookDao.get(id);
	}
	public void getBycontains(Page<Book> page){
		bookDao.getBycontain(page);
	}
	@Transactional
	public void updateBook(Book book){
		bookDao.update(book);
	}
	@CacheEvict(value = "books", allEntries=true)//清除缓存
	public void clean(){
		
	}

}
